//
//  BaseData.m
//  BosidengIphone
//
//  Created by  on 11-12-28.
//  Copyright (c) 2011年 __MyCompanyName__. All rights reserved.
//

#import "BaseData.h"
#import "AppDelegate.h"

@implementation BaseData

@synthesize language;
@synthesize noSaveData;

- (id)init {
    if (self = [super init]) {
        noSaveData = [[NSMutableDictionary alloc] init];
    }
    return self;
}

- (void)dealloc {
    [noSaveData release];
    [language release];
    [super dealloc];
}

+ (NSString *)getItemQueryString:(NSString *)uidName value:(NSString *)uid {
    NSString *query = [NSString stringWithFormat:@"WHERE %@ = '%@' AND language='%@'", uidName, uid, [AppDelegate getLanguage]];
    return query;
}

+ (NSString *)getAllItemsQueryString {
    NSString *query = [NSString stringWithFormat:@"WHERE language='%@'", [AppDelegate getLanguage]];
    return query;
}

+ (id)getItemByID:(NSString *)uid {
    return [BaseData findFirstByCriteria:[BaseData getItemQueryString:@"id" value:uid]];
}

+ (NSArray *)getAllItems {
    return [BaseData findByCriteria:[BaseData getAllItemsQueryString]];
}

- (void)setValue:(NSDictionary *)data {
    self.language = [AppDelegate getLanguage];
}

- (NSString *)formatStringData:(NSString *)data {
    if (data == nil || data.length == 0) {
        return @" ";
    }
    return data;
}

- (NSString *)formatNumberData:(NSString *)data {
    if (data == nil || data.length == 0) {
        return @"0";
    }
    return data;
}

- (CGFloat)getHeight {
    return 120;
}

- (NSInteger)getTextHeight:(NSString*)str cx:(NSInteger)cx font:(UIFont*)font {
	
	CGSize bounds = CGSizeMake( cx, 100000 );
	
	CGSize size = [str sizeWithFont:font constrainedToSize:bounds lineBreakMode:UILineBreakModeTailTruncation];
	
	return size.height;
}

- (void)removeLocalImages {
    ;
}

@end
